import { defineStore } from 'pinia'
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import Main from '@/views/Main.vue'

export const useMenuStore = defineStore('menu', () => {
    const menuList = ref<any[]>([])
    const router = useRouter()
    const setMenuList = (data:any[]) => {
        menuList.value = data;
    }

    const setActiveMenu = (menuName: string) => {
        router.push({
            name: menuName
        });
    }                                                    
    // 以对象的形式把state和action return出去
    return { menuList, setMenuList, setActiveMenu }
})